package com.amsp.oa.oademo.service.impl;

import com.amsp.oa.oademo.entity.LaborTermination2;
import com.amsp.oa.oademo.mapper.LaborTermination2Mapper;
import com.amsp.oa.oademo.service.LaborTermination2Service;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.StringUtils;

import java.util.List;

@Service
public class LaborTermination2ServiceImpl extends ServiceImpl<LaborTermination2Mapper, LaborTermination2>
        implements LaborTermination2Service {

    @Override
    public IPage<LaborTermination2> getPage(Page<LaborTermination2> page, String bparty) {
        LambdaQueryWrapper<LaborTermination2> wrapper = new LambdaQueryWrapper<>();
        if (StringUtils.hasText(bparty)) {
            wrapper.like(LaborTermination2::getBparty, bparty);
        }
        wrapper.orderByDesc(LaborTermination2::getCreateTime);
        return baseMapper.selectPage(page, wrapper);
    }

    @Override
    @Transactional(rollbackFor = Exception.class)
    public boolean saveOrUpdateBatchTran(List<LaborTermination2> laborTerminations) {
        return super.saveOrUpdateBatch(laborTerminations);
    }
}